﻿using NiYo.ParserBuilder.Domain.Hl7.Enums;

namespace NiYo.ParserBuilder.Core.Hl7.Helpers
{
    /// <summary>
    /// See HL7 v2.4 documentation: Chapter 2.17.3 (Message Structure Table)
    /// HL7 Table 0354 - Message structure 
    /// </summary>
    internal static class MessageStructureHelper
    {
        public static string GetMessageStructure(TriggerEvent triggerEvent)
        {
            MessageStructure structure;
            switch (triggerEvent)
            {
                case TriggerEvent.A01: structure = MessageStructure.ADT_A01; break;
                case TriggerEvent.A02: structure = MessageStructure.ADT_A02; break;
                case TriggerEvent.A03: structure = MessageStructure.ADT_A03; break;
                case TriggerEvent.A04: structure = MessageStructure.ADT_A01; break;
                case TriggerEvent.A05: structure = MessageStructure.ADT_A05; break;
                case TriggerEvent.A06: structure = MessageStructure.ADT_A06; break;
                case TriggerEvent.A07: structure = MessageStructure.ADT_A06; break;
                case TriggerEvent.A08: structure = MessageStructure.ADT_A01; break;
                case TriggerEvent.A09:
                case TriggerEvent.A10:
                case TriggerEvent.A11:
                case TriggerEvent.A12: structure = MessageStructure.ADT_A09; break;
                case TriggerEvent.A13: structure = MessageStructure.ADT_A01; break;
                case TriggerEvent.A14: structure = MessageStructure.ADT_A05; break;
                case TriggerEvent.A15: structure = MessageStructure.ADT_A15; break;
                case TriggerEvent.A16: structure = MessageStructure.ADT_A16; break;
                case TriggerEvent.A17: structure = MessageStructure.ADT_A17; break;
                case TriggerEvent.A18: structure = MessageStructure.ADT_A18; break;
                case TriggerEvent.A19: structure = MessageStructure.ADR_A19; break;
                case TriggerEvent.A20: structure = MessageStructure.ADT_A20; break;
                case TriggerEvent.A21:
                case TriggerEvent.A22:
                case TriggerEvent.A23: structure = MessageStructure.ADT_A21; break;
                case TriggerEvent.A24: structure = MessageStructure.ADT_A24; break;
                case TriggerEvent.A25:
                case TriggerEvent.A26:
                case TriggerEvent.A27: structure = MessageStructure.ADT_A21; break;
                case TriggerEvent.A28: structure = MessageStructure.ADT_A05; break;
                case TriggerEvent.A29: structure = MessageStructure.ADT_A21; break;
                case TriggerEvent.A30: structure = MessageStructure.ADT_A30; break;
                case TriggerEvent.A31: structure = MessageStructure.ADT_A05; break;
                case TriggerEvent.A32: structure = MessageStructure.ADT_A21; break;
                case TriggerEvent.A33: structure = MessageStructure.ADT_A21; break;
                case TriggerEvent.A34:
                case TriggerEvent.A35:
                case TriggerEvent.A36: structure = MessageStructure.ADT_A30; break;
                case TriggerEvent.A37: structure = MessageStructure.ADT_A37; break;
                case TriggerEvent.A38: structure = MessageStructure.ADT_A38; break;
                case TriggerEvent.A39:
                case TriggerEvent.A40:
                case TriggerEvent.A41:
                case TriggerEvent.A42: structure = MessageStructure.ADT_A39; break;
                case TriggerEvent.A43:
                case TriggerEvent.A44: structure = MessageStructure.ADT_A43; break;
                case TriggerEvent.A45: structure = MessageStructure.ADT_A45; break;
                case TriggerEvent.A46:
                case TriggerEvent.A47:
                case TriggerEvent.A48:
                case TriggerEvent.A49: structure = MessageStructure.ADT_A30; break;
                case TriggerEvent.A50:
                case TriggerEvent.A51: structure = MessageStructure.ADT_A50; break;
                case TriggerEvent.A52:
                case TriggerEvent.A53: structure = MessageStructure.ADT_A52; break;
                case TriggerEvent.A54: structure = MessageStructure.ADT_A54; break;
                case TriggerEvent.A55: structure = MessageStructure.ADT_A52; break;
                case TriggerEvent.A60: structure = MessageStructure.ADT_A60; break;
                case TriggerEvent.A61:
                case TriggerEvent.A62: structure = MessageStructure.ADT_A61; break;
                case TriggerEvent.M02: structure = MessageStructure.MFN_M02; break;
                default:
                    return null;
            }
            return structure.ToString();
        }
    }
}
